<?xml version="1.0" encoding="utf-8" ?>
<sqlMap namespace="TOrganization" xmlns="http://ibatis.apache.org/mapping" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<alias>
    <typeAlias alias="TOrganization" type="EIA.PM.Model.TOrganization, EIA.PM.Model" />
</alias>

<resultMaps>
<resultMap id="select-torganization-result" class="TOrganization">
<constructor>
    <argument argumentName="org_id" column="org_id"/>
    <argument argumentName="org_name" column="org_name"/>
    <argument argumentName="org_des" column="org_des"/>
    <argument argumentName="org_type" column="org_type"/>
</constructor>
<!--
    <result property="OrgId" column="org_id"/>
    <result property="OrgName" column="org_name"/>
    <result property="OrgDes" column="org_des"/>
    <result property="OrgType" column="org_type"/>
-->
</resultMap>
</resultMaps>

<statements>
<sql id="sql_TOrganization_where_pk">
WHERE org_id=#OrgId#
</sql>

<sql id="sql_TOrganization_where_cv">
<dynamic prepend="WHERE">
    <isPropertyAvailable property="OrgId" prepend="AND">org_id=#OrgId#</isPropertyAvailable>
    <isPropertyAvailable property="OrgName" prepend="AND">org_name LIKE concat('%', #OrgName#, '%')</isPropertyAvailable>
    <isPropertyAvailable property="OrgDes" prepend="AND">org_des LIKE concat('%', #OrgDes#, '%')</isPropertyAvailable>
    <isPropertyAvailable property="OrgType" prepend="AND">org_type=#OrgType#</isPropertyAvailable>
</dynamic>
</sql>

<sql id="sql_TOrganization_set_cols">
<dynamic prepend="SET">
    <isPropertyAvailable property="OrgName" prepend=",">org_name=#OrgName#</isPropertyAvailable>
    <isPropertyAvailable property="OrgDes" prepend=",">org_des=#OrgDes#</isPropertyAvailable>
    <isPropertyAvailable property="OrgType" prepend=",">org_type=#OrgType#</isPropertyAvailable>
</dynamic>
</sql>

<select id="SelectTOrganization" parameterClass="" resultMap="TOrganization.select-torganization-result">
SELECT *
FROM t_organization
<include refid="sql_TOrganization_where_pk"/><!--where-->
</select>

<select id="SelectTOrganization_CV" parameterClass="System.Collections.IDictionary" resultMap="TOrganization.select-torganization-result">
SELECT *
FROM t_organization
<include refid="sql_TOrganization_where_cv"/><!--where-->
</select>

<insert id="InsertTOrganization" parameterClass="TOrganization">
<!--pre selectKey place-->
INSERT INTO t_organization(
<dynamic prepend=" ">
    <isPropertyAvailable property="OrgName" prepend=",">org_name</isPropertyAvailable>
    <isPropertyAvailable property="OrgDes" prepend=",">org_des</isPropertyAvailable>
    <isPropertyAvailable property="OrgType" prepend=",">org_type</isPropertyAvailable>
</dynamic>
)VALUES(
<dynamic prepend=" ">
    <isPropertyAvailable property="OrgName" prepend=",">#OrgName#</isPropertyAvailable>
    <isPropertyAvailable property="OrgDes" prepend=",">#OrgDes#</isPropertyAvailable>
    <isPropertyAvailable property="OrgType" prepend=",">#OrgType#</isPropertyAvailable>
</dynamic>
)
<selectKey resultClass="int" type="post" property="OrgId" >
SELECT LAST_INSERT_ID()
</selectKey>
</insert>

<update id="UpdateTOrganization" parameterClass="System.Collections.IDictionary">
UPDATE t_organization
<include refid="sql_TOrganization_set_cols"/><!--set-->
<include refid="sql_TOrganization_where_pk"/><!--where-->
</update>

<delete id="DeleteTOrganization" parameterClass="">
DELETE FROM t_organization
<include refid="sql_TOrganization_where_pk"/><!--where-->
</delete>

<statement id="DeleteTOrganization_CV" parameterClass="TOrganization">
DELETE FROM t_organization
<include refid="sql_TOrganization_where_cv"/><!--where-->
</statement>

<delete id="ClearTOrganization">
DELETE FROM t_organization
</delete>
</statements>
</sqlMap>